<template>
	<view class="user-index" :data-theme="theme()" :class="theme() || ''">
		<!--个人信息-->
		<!-- v-if="!loadding" -->
		<view>
			<view class="userlogin">
				<view class="content">
					<view style="d-c-c">
						<image v-if="userInfo.avatarUrl != ''" :src="userInfo.avatarUrl" mode="aspectFill" @click="lookImage(userInfo.avatarUrl)"></image>
						<image v-else :src="baseurl + '/image/wxpng/picture.png'" mode="aspectFill"></image>
					</view>
					<view class="text">
						<view class="text1 ml20">
							<view v-if="!takendata" style="border: none; font-size: 36rpx; border-radius: 60rpx; height: 80rpx; line-height: 80rpx" @click="denglu()">
								点击登录
							</view>
							<view v-else style="border: none; font-size: 36rpx; border-radius: 60rpx; height: 80rpx; line-height: 80rpx">
								{{ detail.mobile }}
							</view>
						</view>
						<view class="text2 ml20">欢迎来到 {{ shopinfo.name }}</view>
					</view>
					<view class="text2" v-if="detail.mobile" style="margin-right: 48rpx" @click="gotoPage('/pages/user/set/set')">
						<image style="width: 20px; height: 20px" :src="baseurl + '/image/wxpng/setting.png'" mode="widthFix"></image>
					</view>
					<view class="text2" v-else style="margin-right: 48rpx">
						<!-- <image style="width: 20px; height: 20px;"
							src="https://shoujizulin3.hzrjkf.com/static/wxpng/2.png" mode="widthFix"> -->
						<!-- 		<image style="width: 20px; height: 20px;" :src="baseurl+'/image/wxpng/setting.png'"
								mode="widthFix"> </image> -->
					</view>
				</view>
			</view>

			<!-- <view class="d-b-c"
				style="height: 176rpx; margin: 32rpx 20rpx; padding: 0 20rpx; background-color: #fff;border-radius: 16rpx;">
				<view class="d-c-c d-c">
					<text class="f32 " style="font-weight: 500; color: #090707;">0</text>
					<text class="f24 mt20" style="font-weight: 400; color: #595959;">收藏夹</text>
				</view>
				<u-line direction='col' length='60rpx'></u-line>
				<view class="d-c-c d-c">
					<text class="f32 " style="font-weight: 500; color: #090707;">0</text>
					<text class="f24 mt20" style="font-weight: 400; color: #595959;">优惠券</text>
				</view>
				<u-line direction='col' length='60rpx'></u-line>
				<view class="d-c-c d-c">
					<text class="f32 " style="font-weight: 500; color: #090707;">0</text>
					<text class="f24 mt20" style="font-weight: 400; color: #595959;">租币</text>
				</view>
				<u-line direction='col' length='60rpx'></u-line>
				<view class="d-c-c d-c">
					<text class="f32 " style="font-weight: 500; color: #090707;">0</text>
					<text class="f24 mt20" style="font-weight: 400; color: #595959;">余额</text>
				</view>
			</view> -->
			<view class="mt20">
				<!--我的资产-->
				<view class="my-assets">
					<view class="my-assets-all">
						<view class="f30 fb">全部订单</view>
						<view
							class="d-c-c"
							style="width: 60px; height: 22px; background: rgba(0, 200, 190, 0.1); border-radius: 19px; color: #00c8be"
							@click="jumpPage('/pages/order/myorder?dataType=all')"
						>
							查看全部
						</view>
					</view>
					<view class="d-b-c w100">
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=payment')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/pay.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.payment != null && orderCount.payment > 0">{{ orderCount.payment }}</text> -->
							</view>
							<text>待付款</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=examine')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/shenhe.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.payment != null && orderCount.payment > 0">{{ orderCount.payment }}</text> -->
							</view>
							<text>待审核</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=delivery')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/fahuo.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.delivery != null && orderCount.delivery > 0">{{ orderCount.delivery }}</text> -->
							</view>
							<text class="">待发货</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=received')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/shouhuo.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.received != null && orderCount.received > 0">{{ orderCount.received }}</text> -->
							</view>
							<text>待收货</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=haveInHand')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/zu.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.comment != null && orderCount.comment > 0">{{ orderCount.comment }}</text> -->
							</view>
							<text>租赁中</text>
						</view>
					</view>

					<view class="d-b-c w100">
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=returned')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/huan.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.payment != null && orderCount.payment > 0">{{ orderCount.payment }}</text> -->
							</view>
							<text>待归还</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=Returning')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/huaning.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.payment != null && orderCount.payment > 0">{{ orderCount.payment }}</text> -->
							</view>
							<text>归还中</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=complete')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/over.png'" mode="widthFix"></image>
								<text class="dot d-c-c" v-if="orderCount.refund != null && orderCount.refund > 0">{{ orderCount.refund }}</text>
							</view>
							<text>已完成</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=cancel')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/cancel.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.received != null && orderCount.received > 0">{{ orderCount.received }}</text> -->
							</view>
							<text>已取消</text>
						</view>
						<view class="item" @click="jumpPage('/pages/order/myorder?dataType=yuqi')">
							<view class="icon-box pr">
								<image :src="baseurl + '/image/wxpng/yuqi.png'" mode="widthFix"></image>
								<!-- <text class="dot d-c-c" v-if="orderCount.comment != null && orderCount.comment > 0">{{ orderCount.comment }}</text> -->
							</view>
							<text>已逾期</text>
						</view>
					</view>
				</view>
				<view class="pursh" @click="handlePursh" v-if="trusteeshipInfo.status === 1">
					<view class="pursh-top">
						<view class="pursh-top-left">我的钱包</view>
						<view class="pursh-top-right">
							查看明细
							<image class="pursh-top-right-icon" src="/static/images/myRight.png" mode=""></image>
						</view>
					</view>
					<view class="pursh-amount">
						<text>¥</text>
						8000
					</view>
				</view>

				<view class="hosting" v-if="trusteeshipInfo.status === 1">
					<view class="hosting-title">托管经营</view>
					<view class="hosting-menu">
						<view class="hosting-menu-item" v-for="item in hostingMenuList" :key="item.name" @click="handleHostingMenuClick(item)">
							<image class="hosting-menu-item-icon" :src="item.url" mode="widthFix"></image>
							{{ item.name }}
						</view>
					</view>
				</view>
				<view v-else class="trusteeshipBanner" @click="trusteeshipClick">
					<image src="@/package-purse/static/images/trusteeshipBanner.png" mode="widthFix"></image>
				</view>
				<view class="my-assets2" @click="sfzrz">
					<view class="my-assets-all2">
						<view class="f32 fb">身份认证</view>
						<view class="d-c-c" style="width: 60px; height: 22px; background: rgba(0, 200, 190, 0.1); border-radius: 19px; color: #00c8be">立即认证</view>
					</view>
					<view class="sfz d-a-c mt20">
						<image :src="baseurl + '/image/sfz/card_bm.png'" mode="widthFix"></image>
						<image :src="baseurl + '/image/sfz/card_zm.png'" mode="widthFix"></image>
					</view>
				</view>

				<!-- <view class="banner">
				<image src="https://i-s2.328888.xyz/2022/06/30/62bd48d1e9d91.gif" mode="widthFix"></image>
			</view> -->
				<!--菜单-->
				<view class="menu-wrap" v-if="menus.length > 0">
					<view class="title">我的服务</view>
					<view class="group-bd f-w">
						<view :class="'item ' + item.icon + '-box'" v-for="(item, index) in menus" :key="index" @click="jumpPage(item.link_url)">
							<template v-if="item.status == 1">
								<view class="icon-round d-c-c">
									<image class="icon-round" :src="item.image_url" mode="widthFix"></image>
								</view>
								<text class="name">{{ item.title }}</text>
							</template>
						</view>

						<!-- <view @click="erweima()" :class="'item ' + '-box'">
							<view class="icon-round d-c-c">
								<image class="icon-round" :src="'https://zuwu.rchz.top/image/menu/setting.png'"
									mode="widthFix"></image>
							</view>
							<text class="name">
								推广
							</text>
						</view>

						<view @click="promotion()" :class="'item ' + '-box'">
							<view class="icon-round d-c-c">
								<image class="icon-round" :src="'https://zuwu.rchz.top/image/menu/setting.png'"
									mode="widthFix"></image>
							</view>
							<text class="name">
								推广列表
							</text>
						</view> -->
					</view>
				</view>

				<!--推荐-->
				<recommendProduct :location="10"></recommendProduct>
			</view>
		</view>
		<Popup :show="isPopup" :width="width" :height="height" :backgroundColor="backgroundColor" :boxShadow="boxShadow" :padding="0" @hidePopup="hidePopupFunc">
			<view class="content ww100">
				<view class="" style="height: 60rpx"></view>
				<view class="main" style="width: 80%; margin: 0 auto">
					<u--input placeholder="请输入手机号" border="surround" v-model="phone"></u--input>
				</view>
				<view class="" style="height: 40rpx"></view>
				<view class="d-b-c" style="padding: 0 64rpx; box-sizing: border-box">
					<u--input
						placeholder="请输入验证码"
						border="none"
						v-model="phoneCode"
						height="40rpx"
						style="border: 1px solid rgba(0, 0, 0, 0.2); padding: 6px 9px; box-sizing: border-box; border-radius: 4px"
					>
						<template slot="suffix">
							<u-code @change="codeChange" seconds="60" changeText="X秒重新获取" ref="uCode"></u-code>
							<u-button @tap="submitValidInfo" :text="tips" type="primary" size="small" style="width: 200rpx"></u-button>
						</template>
					</u--input>
				</view>
				<view class="" style="height: 40rpx"></view>
				<view class="wrap" style="width: 40%; margin: 0 auto">
					<u-button @tap="login" type="primary">提交</u-button>
				</view>
			</view>
			<view class="close-btns" @tap="hidePopupFunc(true)"><text class="icon iconfont icon-guanbi"></text></view>
		</Popup>
	</view>
</template>

<script>
import config from '@/config.js';
import recommendProduct from '@/components/recommendProduct/recommendProduct.vue';
import Popup from '@/components/uni-popup.vue';
import baseurl from '@/config.js';
import { trusteeship } from '@/api';
export default {
	components: {
		Popup,
		recommendProduct
	},
	data() {
		return {
			trusteeshipInfo: null,
			hostingMenuList: [
				{
					name: '托管商品',
					url: require('@/static/images/myShop.png'),
					path: '/package-purse/productManagement/productManagement'
				},
				{
					name: '出租管理',
					url: require('@/static/images/forRent.png'),
					path: '/package-purse/rentalManagement/index'
				},
				{
					name: '操作手册',
					url: require('@/static/images/operation.png')
					// path:'/package-purse/rentalManagement/index'
				}
			],
			app_url: config.app_url,
			tips: '',
			phone: '',
			phoneCode: '',
			/*是否显示*/
			isPopup: false,
			/*宽度*/
			width: 600,
			/*高度*/
			height: 800,
			/*背景颜色*/
			backgroundColor: '#fff',
			/*阴影*/
			boxShadow: 'none',
			baseurl: '',
			shopinfo: '',
			isloadding: true,
			/*签到数据*/
			sign: {},
			/*是否加载完成*/
			loadding: true,
			indicatorDots: true,
			autoplay: true,
			interval: 2000,
			duration: 500,
			/*菜单*/
			menus: [],
			detail: {
				balance: 0,
				points: 0,
				grade: {
					name: ''
				}
			},
			is_recycle: 0,
			orderCount: {},
			coupon: 0,
			setting: {},
			user_type: '', //用户状态
			msgcount: 0, //用户未读消息
			sessionKey: '',
			store: '',
			takendata: '',
			userInfo: {}
		};
	},
	onPullDownRefresh() {
		let self = this;
		self.getData();
		self.getDatapage();
	},
	onShow() {
		// 获取托管经营用户信息
		this.getTrusteeshipInfo();

		this.takendata = uni.getStorageSync('token');

		/*获取个人中心数据*/
		this.getData();
		this.getData1();

		// my.navigateTo({
		// 	url: `plugin://esign/home?flowId=${12125122}`,
		// })
	},
	onLoad() {
		this.takendata = uni.getStorageSync('token');
		this.baseurl = baseurl.app_url;
		// uni.setNavigationBarColor({
		// 	frontColor: '#000000',
		// 	backgroundColor: '#284A94',
		// })
		let self = this;
		//#ifdef MP-WEIXIN
		wx.login({
			success(res) {
				// 发送用户信息
				self._post(
					'user.user/getSession',
					{
						code: res.code
					},
					(result) => {
						self.sessionKey = result.data.session_key;
					}
				);
			}
		});
		//#endif
	},
	methods: {
		lookImage: function (e) {
			uni.previewImage({
				urls: [e]
			});
		},
		// 获取托管经营用户信息
		async getTrusteeshipInfo() {
			const res = await trusteeship.trusteeshipDetail();
			this.trusteeshipInfo = res.data || null;
		},
		//申请成为托管经营用户
		trusteeshipClick() {
			if (!this.trusteeshipInfo) {
				uni.navigateTo({
					url: '/package-purse/hostedCertification/hostedCertification'
				});
			} else {
				switch (this.trusteeshipInfo.status) {
					case 0:
						uni.showToast({
							icon: 'none',
							title: '您的申请已提交，请勿重复申请'
						});
						break;
					case 2:
						uni.showToast({
							icon: 'none',
							title: '您的上次申请已被驳回，请重新申请'
						});
						setTimeout(() => {
							uni.navigateTo({
								url: '/package-purse/hostedCertification/hostedCertification'
							});
						}, 1200);
						break;
					case 3:
						uni.showToast({
							icon: 'none',
							title: '该功能已被禁用'
						});
						break;
				}
			}
		},
		// 处理托管菜单点击
		handleHostingMenuClick(item) {
			// 防止重复点击
			if (this.isNavigating) return;
			this.isNavigating = true;

			try {
				if (item.path) {
					uni.navigateTo({
						url: item.path,
						complete: () => {
							setTimeout(() => {
								this.isNavigating = false;
							}, 1000); // 1秒后重置状态
						}
					});
				} else {
					uni.showToast({
						title: '功能开发中',
						icon: 'none',
						complete: () => {
							this.isNavigating = false;
						}
					});
				}
			} catch (error) {
				this.isNavigating = false;
			}
		},
		handlePursh() {
			uni.navigateTo({
				url: '/package-purse/purseDetail/purseDetail'
			});
		},
		threeCertify() {
			const self = this;
			return new Promise((resolve, reject) => {
				self._post(
					'user.user/getSmsCode',
					{
						mobile: self.phone
					},
					(res) => {
						uni.hideLoading();
						if (res.code !== 1) {
							uni.showModal({
								title: '认证失败，请重新认证',
								content: res.msg,
								showCancel: true,
								success: ({ confirm, cancel }) => {}
							});
							return reject();
						}
						resolve(res);
					}
				);
			});
		},
		async submitValidInfo() {
			if (this.phone == '') {
				uni.showToast({
					title: '手机号不能为空',
					icon: 'none'
				});
				return;
			}
			if (this.$refs.uCode.canGetCode) {
				// 模拟向后端请求验证码
				uni.showLoading({
					title: '正在获取验证码'
				});

				// 提交信息获取验证码
				// 获取认证流程id
				const res = await this.threeCertify();
				uni.hideLoading();
				// 这里此提示会被this.start()方法中的提示覆盖
				uni.$u.toast('验证码已发送');
				// 通知验证码组件内部开始倒计时
				this.$refs.uCode.start();
			} else {
				uni.$u.toast('倒计时结束后再发送');
			}
		},
		codeChange(text) {
			this.tips = text;
		},
		login() {
			let token = uni.getStorageSync('token');
			if (this.phone === '')
				return uni.showToast({
					title: '请输入手机号',
					icon: 'none'
				});
			if (this.phoneCode === '')
				return uni.showToast({
					title: '请输入验证码',
					icon: 'none'
				});

			this._post(
				'user.user/bindphone',
				{
					mobile: this.phone,
					code: this.phoneCode,
					token
				},
				(res) => {
					uni.showToast({
						title: '绑定成功'
					});
					this.getData();
					this.isPopup = false;
				}
			);
		},
		dengluphone() {
			this.isPopup = true;
		},
		/*关闭弹窗*/
		hidePopupFunc(e) {
			this.isPopup = false;
			this.phone = '';
		},
		// 退出登录
		tuichu() {
			uni.showToast({
				title: '退出成功！',
				duration: 1000,
				position: 200
			});
			uni.removeStorageSync('token');
			uni.removeStorageSync('user_id');
			setTimeout(function () {
				location.reload();
			}, 1000);
		},
		//跳转手机号登录
		denglu() {
			uni.navigateTo({
				url: './phoneLogin'
			});
			// if (navigator.userAgent.indexOf('MicroMessenger') > -1) {
			// 	// 当前是微信浏览器
			// 	this._post('user.usermp/login', {
			// 		referee_id: 0
			// 	}, res => {
			// 		window.location.href = res.data
			// 	})
			// } else {
			// 	// 不在微信浏览器中，弹窗提示用户
			// 	uni.showModal({
			// 		title: '提示',
			// 		content: '为了获得更好的体验，建议您在微信浏览器中打开此页面',
			// 		showCancel: false,
			// 	});
			// }
		},
		// 领取会员卡
		onOpenCard() {
			var plugin = requirePlugin('alipassToolKit'); // 引用名称需与 app.json 中定义名称相
			let params = {
				cardParams: {
					//开卡入参，
					templateId: this.store.template_id, // 开卡的卡模板ID
					templateAppId: this.store.app_id, // 卡模板ID 所关联的 AppId
					outString: '', //商家自定义透传信息
					pageType: 'half' //默认是 half
				},
				callback: function (res) {
					if (res.success === true) {
					}
				}
			};
			// console.log("领取权益",params);
			plugin.openCard(params); // 接口参数说明如下
		},
		// 订阅
		dingyue() {
			my.requestSubscribeMessage({
				//需要用户订阅的消息模板的id的集合
				entityIds: ['f558d5ee8d4c47889d9dae89887bc0ad', '0e59fbc3303845b29a4f2c4542705ee0', 'fb0d0d4a75b74a3995f2704958b1be99'],
				success: (res) => {
					my.requestSubscribeMessage({
						//需要用户订阅的消息模板的id的集合
						entityIds: ['48bb6e114d7546a6ae3bbad2f48b1b30'],
						success: (res) => {
							console.log('接口调用成功的回调', res);

							this._post(
								'user.user/realNameAuthentication',
								{
									hastongzhi: 1
								},
								function (res) {
									// console.log(res);
								}
							);

							if (res.behavior == 'subscribe') {
								uni.showToast({
									title: '你已经订阅过了！',
									duration: 1000,
									position: 200
								});
							}
						},
						fail: (res) => {
							console.log('接口调用失败的回调', res);
						},
						complete: (res) => {
							// console.log("接口调用结束的回调", res)
						}
					});
				},
				fail: (res) => {
					// console.log("接口调用失败的回调", res);
					my.requestSubscribeMessage({
						//需要用户订阅的消息模板的id的集合
						entityIds: ['48bb6e114d7546a6ae3bbad2f48b1b30'],
						success: (res) => {
							console.log('接口调用成功的回调', res);

							// this._post('user.user/realNameAuthentication', {
							// 	hastongzhi:1
							// }, function(res) {
							// 	// console.log(res);
							// });

							if (res.behavior == 'subscribe') {
								uni.showToast({
									title: '你已经订阅过了！',
									duration: 1000,
									position: 200
								});
							}
						},
						fail: (res) => {
							console.log('接口调用失败的回调', res);
						},
						complete: (res) => {
							// console.log("接口调用结束的回调", res)
						}
					});
				},
				complete: (res) => {
					// console.log("接口调用结束的回调", res)
				}
			});
		},
		// 跳转订单页面
		sfzrz2() {
			uni.navigateTo({
				url: "/pages/order/myorder?dataType=all'"
			});
		},
		// 跳转认证
		sfzrz() {
			uni.navigateTo({
				url: '/pages/user/authentication'
			});
		},
		// 支付宝登录
		async onGetAuthorize1() {
			// 获取授权码
			my.getAuthCode({
				scopes: ['auth_base'],
				success: (res) => {
					my.getPhoneNumber({
						success: (res1) => {
							let encryptedData = res1.response;
							encryptedData = JSON.parse(encryptedData);
							let response = encryptedData.response;
							this._post(
								'user.usermp/mnpAlipayAuthLogin',
								{
									code: res.authCode,
									content: response
								},
								(res) => {
									uni.setStorageSync('token', res.data.data.token);
									uni.setStorageSync('user_id', res.data.data.user_id);
									uni.showToast({
										title: '登录成功'
									});
									this.getData();
									this.dingyue();
								}
							);
						},
						fail: (res) => {
							console.log('失败');
							reject(res);
						}
					});
				}
			});
		},
		// 拒绝操作
		onAuthError() {
			uni.showModal({
				title: '提示',
				content: '取消授权，可能导致服务无法使用，或者页面显示不完整',
				success: function (res) {
					if (res.confirm) {
						console.log('取消授权');
					} else {
						console.log('重新授权');
					}
				}
			});
		},

		// 获取手机号
		async onGetAuthorize() {
			let self = this;
			my.getOpenUserInfo({
				success: (res) => {
					const userInfo = JSON.parse(res.response);
					if (userInfo.response.code != '10000') {
						uni.showToast({
							title: '绑定失败'
						});
						return;
					}
					this._post(
						'user.usermp/changeuserinfo',
						{
							avatar: userInfo.response.avatar,
							nickName: userInfo.response.nickName
						},
						(res) => {
							uni.showToast({
								title: '绑定成功'
							});
							this.getData();
						}
					);
				},
				fail: (res) => {
					console.log(res);
				}
			});
		},

		/*获取数据*/
		getData1() {
			let self = this;
			uni.showLoading({
				title: '加载中'
			});
			self._get('index/index', {}, function (res) {
				self.store = res.data.setting.store;
				self.shopinfo = res.data.page.params;
				// console.log("res",self.store);
				// console.log("self.shopinfo",self.shopinfo);
				// if (baseurl.app_url == "https://huichu.haidiao888.com/") {
				// 	// console.log("huichu");
				// 	let a = res.data.page.params.name;
				// 	self.shopinfo.tiname = a.substr(0, 3);
				// } else if (baseurl.app_url == "https://shoujizulin2.rchz.top/") {
				// 	// console.log("mxy");
				// 	let a = res.data.page.params.name;
				// 	self.shopinfo.tiname = a.substr(0, 4);
				// } else if (baseurl.app_url == "https://yunxiangzu.rchz.top/") {
				// 	// console.log("ybt");
				// 	let a = res.data.page.params.name;
				// 	self.shopinfo.tiname = a.substr(0, 3);
				// } else if (baseurl.app_url == "https://zidizulin.rchz.top/") {
				// 	// console.log("dzzl");
				// 	let a = res.data.page.params.name;
				// 	self.shopinfo.tiname = a.substr(0, 4);
				// }

				// uni.setNavigationBarTitle({
				// 	title: res.data.page.params.name,
				// 	success: () => {
				// 		// console.log('修改标题成功')
				// 	},
				// 	fail: () => {
				// 		// console.log('修改标题失败')
				// 	},
				// 	complete: () => {
				// 		// console.log('修改标题结束')
				// 	},
				// })
				self.loadding = false;
				uni.hideLoading();
			});
		},

		/*获取数据*/
		getData() {
			let self = this;
			let token = uni.getStorageSync('token');
			self.isloadding = true;
			self._get('user.index/detail', {url: self.url, token},
				function (res) {
					self.takendata = uni.getStorageSync('token') || '';
					let username = res.data.userInfo.username;
					let usernum = res.data.userInfo.usernum;
					uni.setStorageSync('username', username);
					uni.setStorageSync('usernum', usernum);
					if (res.data.getPhone) {
						//#ifdef MP-WEIXIN
						// self.gotoPage('/pages/login/bindmobile');
						self.gotoPage('/pages/user/index/index');
						//#endif
						//#ifndef MP-WEIXIN
						self.bindMobile();
						//#endif
						return;
					}
					if (res.data.userInfo.address_id) {
						uni.setStorageSync('addressId', res.data.userInfo.address_id);
					}
					self.userInfo = res.data.userInfo;
					if (res.data.userInfo.avatarUrl != '') {
						if (self.userInfo.avatarUrl.slice(0, 4) == 'http') {
							self.userInfo.avatarUrl = self.userInfo.avatarUrl;
						} else {
							self.userInfo.avatarUrl = baseurl.static_url  + self.userInfo.avatarUrl;
						}
					}
          console.log('avatarUrl============',self.userInfo.avatarUrl)
					self.detail = res.data.userInfo;
					self.detail.favorite = res.data.favorite;
					self.sign = res.data.sign;
					self.coupon = res.data.coupon;
					self.orderCount = res.data.orderCount;
					self.menus = res.data.menus;
					self.setting = res.data.setting;
					self.is_recycle = res.data.userInfo.is_recycle;
					self.msgcount = res.data.msgcount;
					self.loadding = false;
					uni.stopPullDownRefresh();
					self.isloadding = false;
				}
			);
		},
		bindMobile() {
			// this.gotoPage('/pages/user/modify-phone/modify-phone');
		},
		/*跳转页面*/
		jumpPage(path) {
			console.log(path, 'path');
			let self = this;
			if (path.startsWith('/')) {
				if (path == '/pages/shop/register') {
					self._post('supplier.apply/detail', {}, function (res) {
						console.log(res.data.detail);
						if (res.data.detail == null) {
							self.gotoPage('/pages/shop/register');
						} else {
							self.gotoPage('/pages/shop/application_status');
						}
					});
				} else {
					self.gotoPage(path);
				}
			} else {
				self[path]();
			}
		},
		/*扫一扫核销*/
		scanQrcode: function () {
			this.gotoPage('/pages/user/scan/scan');
		},
		getPhoneNumber(e) {
			var self = this;
			if (e.detail.errMsg !== 'getPhoneNumber:ok') {
				return false;
			}
			uni.showLoading({
				title: '加载中'
			});
			uni.login({
				success(res) {
					// 发送用户信息
					self._post(
						'user.user/bindMobile',
						{
							session_key: self.sessionKey,
							encrypted_data: e.detail.encryptedData,
							iv: e.detail.iv
						},
						(result) => {
							uni.showToast({
								title: '绑定成功'
							});
							// 执行回调函数
							self.detail.mobile = result.data.mobile;
						},
						false,
						() => {
							uni.hideLoading();
						}
					);
				}
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.hosting {
	padding: 30rpx 20rpx 10rpx;
	background: #ffffff;
	border-radius: 10rpx;
	margin: 0 20rpx;
	&-title {
		font-family: 'PingFang SC';
		font-weight: bold;
		font-size: 33rpx;
		color: #333333;
		margin-bottom: 40rpx;
	}
	&-menu {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
		&-item {
			width: 25%;
			text-align: center;
			font-family: 'PingFang SC';
			font-weight: 400;
			font-size: 24rpx;
			color: #333333;
			margin-bottom: 40rpx;
			&-icon {
				width: 48rpx;
				height: 48rpx;
				margin: 0 auto 20rpx auto;
			}
		}
	}
}
.trusteeshipBanner {
	padding: 0rpx 20rpx 0rpx;
	image {
		width: 100%;
		height: 244.6rpx;
	}
}
.pursh {
	margin: 20rpx;
	position: relative;
	height: 200rpx;
	background-image: url('https://yundong-shop.oss-cn-shanghai.aliyuncs.com/2025091422500215fe90400.png');
	background-repeat: no-repeat;
	background-size: cover;
	background-position: center center;
	&-top {
		position: relative;
		z-index: 2;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding-top: 30rpx;
		&-left {
			padding-left: 37rpx;
			font-family: 'PingFang SC';
			font-weight: bold;
			font-size: 30rpx;
			color: #333333;
		}
		&-right {
			width: 154rpx;
			height: 44rpx;
			background: rgba(253, 132, 25, 0.1);
			border-radius: 4rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-family: 'PingFang SC';
			font-weight: 400;
			font-size: 24rpx;
			color: #666666;
			&-icon {
				margin-left: 10rpx;
				width: 13rpx;
				height: 23rpx;
			}
		}
	}
	&-amount {
		margin: 20rpx 0 0 37rpx;
		position: relative;
		z-index: 2;
		font-family: 'PingFang SC';
		font-weight: bold;
		font-size: 48rpx;
		color: #ff4400;
		text {
			font-size: 30rpx;
		}
	}
}
.close-btns {
	margin: 50rpx auto 0;
	width: 60rpx;
	height: 60rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	border-radius: 50%;
	background: none;
	border: 2px solid #ffffff;
}

.lodingBtn {
	border: none;
	font-size: 36rpx;
	border-radius: 60rpx;
	height: 80rpx;
	line-height: 80rpx;
	// background-color: #284A94;
	// color: white;
}

.QRcode {
	image {
		width: 500rpx;
		height: 500rpx;
	}

	padding: 0 20rpx;
	padding-top: 50rpx;

	h3 {
		text-align: center;
	}
}

.qkan {
	background-color: transparent;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 0;
	color: transparent;

	padding: 0 10rpx;
	text-align: center;
	background-color: #ebc899;
	color: #7a6b65;
	border-radius: 25rpx;
	font-size: 24rpx;
	font-weight: bold;
}

.vipContent {
	margin: 0 50rpx;
	background-color: #40415d;
	height: 100rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 0 20rpx;
	border-left: 1rpx #7e6273 solid;
	border-right: 1rpx #7e6273 solid;
	border-top-left-radius: 25rpx;
	border-top-right-radius: 25rpx;

	.left {
		display: flex;
		align-items: center;

		.vip {
			// width: 70rpx;
			// height: 70rpx;
			display: flex;
			align-items: center;

			image {
				width: 70rpx;
				height: 60rpx;
			}
		}

		.text {
			color: #ead2a9;

			.textTop {
				font-size: 25rpx;
				margin: 10rpx;
			}

			.textBottom {
				font-size: 22rpx;
				margin: 10rpx;
			}
		}
	}

	.right {
		padding: 10rpx 25rpx;
		text-align: center;
		background-color: #ebc899;
		color: #7a6b65;
		border-radius: 25rpx;
		font-size: 24rpx;
		font-weight: bold;
	}
}

.my-assets2 {
	margin: 20rpx 20rpx;
	padding: 40rpx 20rpx;
	padding-top: 0;
	background: #ffffff;
	border-radius: 12rpx;
}

.my-assets-all2 {
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: 80rpx;
}

.sfz {
	image {
		width: 140px;
		height: 76px;
	}
}

.userlogin {
	width: 100%;
	height: 164rpx;
	// height: 500rpx;
	// border-bottom-left-radius: 50rpx;
	// border-bottom-right-radius: 50rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	background-color: #ffffff;

	.content {
		width: 100%;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 0 24rpx;

		view {
			margin-right: 30rpx;

			image {
				width: 104rpx;
				height: 104rpx;
				border-radius: 50%;
			}
		}

		.text {
			flex: 1 1 0%;
		}
	}

	.text {
		// color: #FFFEFE;

		// margin-top: 25rpx;
		.text1 {
			font-size: 36rpx;
			font-family: 'Microsoft Yahei';
		}

		.text2 {
			font-size: 30rpx;
			font-family: 'Microsoft Yahei';
		}
	}
}

.wenzi {
	color: #4e5561;
	font-weight: 700;
	font-size: 38rpx;
}

.gang {
	width: 20%;
	height: 2rpx;
	background: #dfdee3;
	margin: 0 15rpx;
}

page {
	background-color: #ebebeb;
}

.banner {
	width: 750rpx;
}

.banner image {
	margin: 0 auto;
	width: 700rpx;
	height: 160rpx !important;
	margin-top: 20rpx;
}

// .d-c {
// 	border-right: 1rpx solid #CCCCCC;
// }

// .d-c:last-child {
// 	border: none;
// }

.user-index {
	// background: linear-gradient(180deg, #FF4646 0%, rgba(86, 213, 200, 0) 30%);
	// background-image: linear-gradient(to bottom, #56D5C8, #fff);
	background: #f8fafb;
}

.w100 {
	width: 100%;
	margin-top: 30rpx;
}

.foot_ {
	height: 98rpx;
	width: 100%;
}

.user-header {
	position: relative;
	// @include background_color('background_color');
}

.gray3 {
	font-size: 30rpx;
	color: #303133;
}

.user-header .user-header-inner {
	position: relative;
	padding: 30rpx 30rpx 120rpx;
	display: flex;
	justify-content: space-between;
	align-items: center;
	overflow: hidden;
	margin-bottom: 100rpx;
}

// .user-header .user-header-inner::after,
// .user-header .user-header-inner::before {
// 	display: block;
// 	content: '';
// 	position: absolute;
// 	border-radius: 50%;
// 	z-index: 0;
// }

// .user-header .user-header-inner::after {
// 	width: 400rpx;
// 	height: 400rpx;
// 	right: -100rpx;
// 	bottom: -200rpx;
// 	background-image: radial-gradient(90deg, rgba(255, 255, 255, 0.2) 10%, rgba(255, 255, 255, 0));
// }

// .user-header .user-header-inner::before {
// 	width: 200rpx;
// 	height: 200rpx;
// 	left: -60rpx;
// 	top: -20rpx;
// 	background-image: radial-gradient(-90deg, rgba(255, 255, 255, 0.2) 10%, rgba(255, 255, 255, 0));
// }

.user-header .user-info {
	display: flex;
	justify-content: flex-start;
	align-items: center;
}

.user-header .photo,
.user-header .photo image {
	width: 100rpx;
	height: 100rpx;
	border-radius: 50%;
}

.user-header .photo {
	border: 4rpx solid #ffffff;
}

.user-header .info {
	padding-left: 20rpx;
	box-sizing: border-box;
	overflow: hidden;
	color: #ffffff;
}

.user-header .info .name {
	color: black;
	// font-weight: bold;
	font-size: 32rpx;
	margin-top: 10rpx;
}

.user-header .info .tel {
	font-size: 26rpx;
	color: black;
}

.user-header .info .grade {
	display: block;
	padding: 4px 16rpx;
	font-size: 22rpx;
	/* height: 36rpx; */
	line-height: 36rpx;
	border-radius: 40rpx;
	background-color: rgba($color: #000000, $alpha: 0.1);
	color: #ffffff;
	font-family: PingFang SC;
}

.user-header .sign-box {
	position: absolute;
	right: 20rpx;
	padding: 0 10rpx;
	height: 50rpx;
	border: 1px solid #ffe300;
	border-radius: 25rpx;
	font-size: 24rpx;
	color: #ffe300;
	z-index: 10;
}

.user-header .sign-box .iconfont {
	color: #ffe300;
}

.user-header .my-order {
	position: absolute;
	padding: 20rpx 10rpx;
	/* height: 240rpx; */
	right: 20rpx;
	bottom: -75rpx;
	left: 20rpx;
	box-sizing: border-box;
	border-radius: 20rpx;
	/* box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.1); */
	background: #ffffff;
	z-index: 10;
}

.order_center {
	border-left: 1rpx solid #d9d9d9;
	border-right: 1rpx solid #d9d9d9;
}

.my-order .item {
	display: flex;
	margin: 20rpx 0;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	font-size: 26rpx;
	flex: 1;
}

.my-assets .icon-box image {
	width: 50rpx;
	height: 50rpx;
	margin-bottom: 16rpx;
}

.my-order .icon-box,
.my-assets .icon-box {
	width: 60rpx;
	height: 60rpx;
}

.my-order .icon-box .iconfont,
.my-assets .icon-box .iconfont {
	font-size: 50rpx;
	color: #333333;
}

.f30 {
	color: #303133;
	font-size: 30rpx;
}

.my-assets .icon-box .dot {
	position: absolute;
	top: -13rpx;
	right: -8rpx;
	height: 25rpx;
	min-width: 25rpx;
	padding: 4rpx;
	border-radius: 20rpx;
	font-size: 20rpx;
	background: #f00808;
	color: #ffffff;
}

.my-assets {
	margin: 0 20rpx;
	padding: 40rpx 20rpx;
	padding-top: 0;
	background: #ffffff;
	border-radius: 12rpx;
}

.my-assets .item {
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}

.my-wallet {
	position: relative;
	width: 200rpx;
	border-left: 1px solid #dddddd;
}

.my-wallet::after {
	position: absolute;
	display: block;
	content: '';
	left: 0;
	border: 8rpx solid transparent;
	border-left-color: #dddddd;
}

.menu-wrap {
	margin: 0 20rpx;
	margin-top: 30rpx;
	background: #ffffff;
	/* box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.1); */
	border-radius: 12rpx;
}

.menu-wrap .title {
	font-size: 30rpx;
	font-weight: bold;
	padding: 20rpx 0rpx 10rpx 20rpx;
	margin-bottom: 30rpx;
	width: 678rpx;
	// border-bottom: 1rpx solid #CCC;
}

.menu-wrap .group-bd {
	display: flex;
	justify-content: flex-start;
	align-items: flex-start;
}

.menu-wrap .item {
	display: flex;
	justify-content: center;
	align-items: center;
	flex-direction: column;
	width: 177rpx;
	height: 150rpx;
	font-size: 24rpx;
}

.menu-wrap .item.icon-dizhi1-box .icon-round {
	background-image: linear-gradient(135deg, #67b4e2 10%, #356dce 70%, #5c8fe8 90%);
}

.menu-wrap .item.icon-youhuiquan1-box .icon-round {
	background-image: linear-gradient(135deg, #e87ea4 10%, #ff268a 70%, #fe0d76 90%);
}

.menu-wrap .item.icon-youhuiquan--box .icon-round {
	background-image: linear-gradient(135deg, #ff5a30 10%, #ff2b3c 70%, #ff1740 90%);
}

.menu-wrap .item.icon-fenxiao1-box .icon-round {
	background-image: linear-gradient(135deg, #7ceeba 10%, #1ed2b7 70%, #17c0ad 90%);
}

.menu-wrap .item.icon-kanjia-box .icon-round {
	background-image: linear-gradient(135deg, #f2a904 10%, #f27d04 70%, #eaa031 90%);
}

.menu-wrap .item.icon-shezhi1-box .icon-round {
	background-image: linear-gradient(135deg, #615f6c 10%, #4c4a58 70%, #615f6c 90%);
}

.menu-wrap .icon-round {
	width: 48rpx;
	height: 48rpx;
	color: #ffffff;
}

.menu-wrap .item .iconfont {
	font-size: 40rpx;
	color: #ffffff;
}

.menu-wrap .item .name {
	margin-top: 19rpx;
}

.bind_phone {
	width: 100%;
	height: 80rpx;
	padding: 0 30rpx;
	box-sizing: border-box;
	margin-bottom: 30rpx;
}

.bind_content {
	display: flex;
	justify-content: space-between;
	align-items: center;
	background: #ffffff;
	/* box-shadow: 0 0 6rpx 0 rgba(0, 0, 0, 0.1); */
	border-radius: 16rpx;
	height: 100%;
	padding: 0 20rpx;
}

.bind_txt {
}

.bind_btn {
	width: 134rpx;
	height: 50rpx;
	line-height: 50rpx;
	font-size: 22rpx;
	border-radius: 25rpx;
	text-align: center;
	color: #ffffff;
	background-color: #e2231a;
}

.vertical {
	position: absolute;
	top: 10px;
	right: 53px;
	z-index: 100000;
}

.vertical_img {
	width: 100rpx;
	height: 100rpx;
}

.f20 {
	margin-left: 5rpx;
	font-size: 19rpx;
}

.red_mini {
	color: #303133;
	font-size: 32rpx;
}

.icon-zhuanshutequan {
	color: #f5dca6;
	margin-right: 3px;
}

.news {
	position: absolute;
	top: 40rpx;
	right: 20rpx;
	z-index: 100;
}

.news .chat {
	width: 60rpx;
	height: 60rpx;
	position: absolute;
	top: 0rpx;
	right: 10rpx;
}

.news .icon-xiaoxi {
	font-size: 50rpx;
	color: #ffffff;
}

.news_num {
	position: absolute;
	top: 24rpx;
	right: 44rpx;
	z-index: 100;
	border-radius: 50%;
	width: 25rpx;
	height: 25rpx;
	text-align: center;
	line-height: 25rpx;
	color: #ffffff;
	background-color: #ff6633;
	padding: 5rpx;
	font-size: 20rpx;
}

.my-assets-all {
	display: flex;
	justify-content: space-between;
	align-items: center;
	height: 80rpx;
	// line-height: 80rpx;
	// border-bottom: 2rpx solid #CCC;
}

.my-assets-all .icon.icon-jiantou {
	font-size: 16px;
	color: #999999;
}

.shoujihao {
	border: none;
	background-color: #ffffff;
}

.shouquan {
	padding: 10rpx;
	font-size: 25rpx;
	font-weight: 300;
	border-radius: 40rpx;
	background-color: #5fa0ff;
	color: white;
}
</style>
